// PGLNumbering.cpp: implementation of the CPGLNumbering class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include <pgl/core/pgl.h>
#include <pgl/core/PGLArchive.h>
#include <pgl/core/PGLNumbering.h>

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

PGL_IMPLEMENT_DYNCREATE(CPGLNumbering,CPGLObject);

#ifdef _DEBUG
void CPGLNumbering::Dump( CDumpContext& dc ) const
{
    // call base class function first
    CPGLObject::Dump( dc );

    // now do the stuff for our specific class
	dc << _T("--- CPGLNumbering ID ") << GetID() <<_T(" ---\n");
}

void CPGLNumbering::AssertValid() const
{
    // call inherited AssertValid first
    CPGLObject::AssertValid();
} 
#endif

void CPGLNumbering::SerializeXML(CPGLArchive& ar)
{
	static const TCHAR szTag[] = _T("CPGLNumbering");

	markup::CMarkupArchive& xml = *((markup::CMarkupArchive*)ar.GetMarkup());
	if(ar.IsStoring())
	{
		xml.AddChildElem(szTag);
		xml.IntoElem();

			/////////////////////////////////////////////////////////
			// Adding base class
			CPGLObject::SerializeXML(ar);

		xml.OutOfElem();
	}
	else
	{
		if  (!xml.FindChildElem(szTag))
				return;

		xml.IntoElem();

			/////////////////////////////////////////////////////////
			// loading base class
			CPGLObject::SerializeXML(ar);

		xml.OutOfElem();
	}
}

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CPGLNumbering::CPGLNumbering(CPGLNumbering::ESide eSide)
: m_eSide( eSide )
{

}

CPGLNumbering::CPGLNumbering(CPGLNumbering const& n_)
{};

CPGLNumbering& CPGLNumbering::operator =(CPGLNumbering const& n_)
{
	return *this;
};

void CPGLNumbering::PlotGfx(
	CPGLRectD const& region_rect_,
	CPGLRectD const& numbering_rect_,
	gfxinterface::CGfxInterface& gfx)
{
	if (!IsVisible())
		return;

	if (!IsInLayer(gfx.GetLayer()))
		return;
	
	m_text.GetFont().SetFontGfx(gfx);

	CPGLObject::PlotGfx(gfx);
}


bool CPGLNumbering::IsHorizontal() const
{
	return m_eSide == SideBottom || m_eSide == SideTop;
}
